#include "input_output.h"

int Hand_time[5];
int N;
int R;
int **Area_information;
int L;
int Loop_n;
int W;
int **Window_information;
int D;
int **Instrument_information;
int E;
int **Graph;
int T;
int *K;
int *F;
int **Edge_idx;

void input()
{
    scanf("%d %d %d %d %d", &Hand_time[0], &Hand_time[1], &Hand_time[2], &Hand_time[3], &Hand_time[4]);
    scanf("%d", &N);
    scanf("%d", &R);
    Area_information = (int**)malloc(R*sizeof(int*));
    for (int i = 0; i < R; ++i) {
        Area_information[i] = (int*) malloc(2*sizeof(int));
        scanf("%d %d", &Area_information[i][0], &Area_information[i][1]);
    }
    scanf("%d", &L);
    scanf("%d", &Loop_n);
    scanf("%d", &W);
    Window_information = (int**)malloc(W*sizeof(int*));
    for (int i = 0; i < W; ++i) {
        Window_information[i] = (int*) malloc(6*sizeof(int));
        scanf("%d %d %d %d %d %d", &Window_information[i][0], &Window_information[i][1],
              &Window_information[i][2], &Window_information[i][3], &Window_information[i][4], &Window_information[i][5]);
    }
    scanf("%d", &D);
    Instrument_information = (int**)malloc(D*sizeof(int*));
    for (int i = 0; i < D; ++i) {
        Instrument_information[i] = (int*) malloc(6*sizeof(int));
        scanf("%d %d %d %d %d %d", &Instrument_information[i][0], &Instrument_information[i][1],
              &Instrument_information[i][2], &Instrument_information[i][3], &Instrument_information[i][4], &Instrument_information[i][5]);
    }
    scanf("%d", &E);
    Graph = (int**)malloc(E*sizeof(int*));
    for (int i = 0; i < E; ++i) {
        Graph[i] = (int*) malloc(3*sizeof(int));
        scanf("%d %d %d", &Graph[i][0], &Graph[i][1], &Graph[i][2]);
    }
    scanf("%d", &T);
    F = (int*)malloc(T*sizeof(int));
    K = (int*)malloc(T*sizeof(int));
    Edge_idx = (int**)malloc(T*sizeof(int*));
    for (int i = 0; i < T; ++i) {
        scanf("%d %d ", &K[i], &F[i]);
        Edge_idx[i] = (int*)malloc(F[i]*sizeof(int));
        for (int j = 0; j < F[i]; ++j) {
            scanf("%d ", &Edge_idx[i][j]);
        }
    }
}

void print_input()
{
    printf("%d %d %d %d %d\n", Hand_time[0], Hand_time[1], Hand_time[2], Hand_time[3], Hand_time[4]);
    printf("%d\n", N);
    printf("%d\n", R);
    for (int i = 0; i < R; ++i) {
        printf("%d %d\n", Area_information[i][0], Area_information[i][1]);
    }
    printf("%d\n", L);
    printf("%d\n", Loop_n);
    printf("%d\n", W);
    for (int i = 0; i < W; ++i) {
        printf("%d %d %d %d %d %d\n", Window_information[i][0], Window_information[i][1], Window_information[i][2],
               Window_information[i][3], Window_information[i][4], Window_information[i][5]);
    }
    printf("%d\n", D);
    for (int i = 0; i < D; ++i) {
        printf("%d %d %d %d %d %d\n", Instrument_information[i][0], Instrument_information[i][1], Instrument_information[i][2],
               Instrument_information[i][3], Instrument_information[i][4], Instrument_information[i][5]);
    }
    printf("%d\n", E);
    for (int i = 0; i < E; ++i) {
        printf("%d %d %d\n", Graph[i][0], Graph[i][1], Graph[i][2]);
    }

    printf("%d\n", T);
    for (int i = 0; i < T; ++i) {
        printf("%d %d ", K[i], F[i]);
        for (int j = 0; j < F[i]; ++j) {
            printf("%d ", Edge_idx[i][j]);
        }
        printf("\n");
    }
}

void output(int k1, int *ans1, int k2, int *colsize, int **ans2){
    printf("%d\n", k1);
    for (int i = 0; i < k1-1; ++i) {
        printf("%d ", ans1[i]);
    }
    printf("%d\n", ans1[k1-1]);

    printf("%d\n", k2);
    for (int i = 0; i < k2; ++i) {
        for (int j = 0; j < colsize[i]-1; ++j) {
            printf("%d ", ans2[i][j]);
        }
        printf("%d\n", ans2[i][colsize[i]-1]);
    }
}
